# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-http_parser.rb
_gemname=http_parser.rb
pkgver=0.8.0
pkgrel=3
pkgdesc="A simple callback-based HTTP request/response parser"
url="https://github.com/tmm1/http_parser.rb"
arch="all"
license="MIT"
depends="ruby"
checkdepends="ruby-rspec"
makedepends="http-parser-dev ruby-dev"
source="https://github.com/tmm1/http_parser.rb/archive/v$pkgver/$pkgname-$pkgver.tar.gz
	remove-broken-test.patch
	use-system-libhttp_parser.patch
	gemspec.patch
	"
builddir="$srcdir/$_gemname-$pkgver"

build() {
	gem build $_gemname.gemspec
	gem install \
		--local \
		--install-dir dist \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname
}

check() {
	GEM_PATH='./dist' rspec .
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"
	cd "$builddir"/dist

	mkdir -p "$gemdir"
	cp -r extensions gems specifications "$gemdir"/

	# Remove unnecessary files and rubbish...
	find "$gemdir"/extensions/ -name mkmf.log -delete

	cd "$gemdir"/gems/$_gemname-$pkgver
	rm -r ext/ lib/*.so
}

sha512sums="
3e98705e5368fb92d6e997ef86a33af0e4aac817f45a1ffc97fc3782e0b6c7f6a4ec09c65b5524e9506c49f703125445c127f00b51adfb8a2a492b5266cf0cec  ruby-http_parser.rb-0.8.0.tar.gz
a38617de20295f4629f159b9b54b9a7ac7e42ff5940b1a9864dbf4a990be8f28f92348583eef176bae0909e1ff36f2d633e80eb3f4a48a8b72574bd1abf08bbc  remove-broken-test.patch
ab5c20e2263966f1a3c00d5738a105b5861fe1c95ab6315ad15cc1d526d115e7ae8e300f114d5da542de2ededd45513f91d515cb8683220d2d6ceea2c376f415  use-system-libhttp_parser.patch
f19b84b1e35513f72161b78e9a713829197eab14bcacbe327826e5f283b661b810b250b3f32efd9c5be39991c0784de45833ea1498367b490797c7051c46a314  gemspec.patch
"
